#include <iostream>
#include <cstring>
using namespace std;

class Employee
{
	public :
		int m_id;
		string m_name;
	public :
		Employee(int id = 1010, string name = "Li Si") :
			m_id(id), m_name(name)
		{
			cout << "<Employee init()>" << endl;
		}

		virtual ~Employee()
		{
			cout << "<~Employee()>" << endl;
		}

		virtual void display()
		{
			cout << "Name : " << m_name << endl;
			cout << "Id   : " << m_id << endl;
		}
};

class Teacher : public Employee
{
	public :
		char *m_subject;
	public :
		Teacher(int id = 1010, string name = "Wang Wu", const char *subject = NULL) :
			Employee(id, name)
		{
			cout << "<Teacher init()>" << endl;
			if(NULL == subject)
			{
				m_subject = new char[1];
				*m_subject = '\0';
			}
			else
			{
				m_subject = new char[strlen(subject) + 1];
				strcpy(m_subject, subject);
			}
		}

		virtual ~Teacher()
		{
			cout << "<~Teacher()>" << endl;
			delete [] m_subject;
			m_subject = NULL;
		}

		void display()
		{
			Employee :: display();
			cout << "Sub  : " << m_subject << endl;
		}
};

int main()
{
	Employee *pe = new Teacher(1001, "Zhang San", "English");
	pe->display();
	delete pe;
}
